package com.amado.course36ByteStream;

import java.io.ByteArrayInputStream;
import java.io.IOException;
/**
 * ByteArrayInputStream 包含一个内部缓冲区，该缓冲区包含从流中读取的字节
 * @author Administrator
 *
 */
public class S04ByteArrayInputStreamTest {
	public static void main(String[] args) {
		byte[] b = {1,2,55,-1,-99,-87};
		//oxff 256 &-99,同时为1则为1
		//oxff 256 &-87
		
		//10011101
		//&
		//11111111
		//10011101
		System.out.println(Integer.toBinaryString(-99));
		
		System.out.println(Integer.toBinaryString(0xff));
		System.out.println(-99&0xff);
		
		System.out.println("二进制"+Integer.parseInt("10011101",2));
		ByteArrayInputStream in = new ByteArrayInputStream(b);
		int i = in.read();
		while(i != -1){
			System.out.println(i);
			//看源码
			i = in.read();
		}
		try {
			in.close();
		} catch (IOException e) {
			e.printStackTrace();
		}

	}
}
